package test;



import java.util.Map;
import java.util.function.Function;

public class th {

    public static int i;

    public static void main(String[] args) {
        insert();
    }
    public static void caculate ( Function<Integer,Void> callback){

       Thread a = new Thread(()->{
           i++;
       });
       Thread b = new Thread(()->{
           i++;
       });
       Thread c = new Thread(()->{
           i++;
       });
       Thread d = new Thread(()->{
           i++;
       });
       Thread f = new Thread(()->{
           i++;
       });
        try {
            a.start();
            b.start();
            c.start();
            d.start();
            f.start();
            a.join();
            b.join();
            c.join();
            d.join();
            f.join();
            callback.apply(i);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }


    }

    public static void insert() {
        caculate((i) ->{
            System.err.println(i);
            return null;
        });
    }

}
